

import java.util.Arrays;
import java.util.Date;
import java.util.Random;

/**
 * @Author: Siantar
 * @Date: 2024-07-17-13:41
 * @Description: 1.0
 */
public class RandomInsertUtils {


    // 公司名称前缀，如常见的地名、行业词汇等
    private static final String[] PREFIXES = {
            "华", "中", "国", "东", "西", "南", "北", "新", "金", "安",
            "鼎", "创", "鼎新", "宏", "巨", "强", "天", "海", "盛", "联"
    };

    // 行业词汇，如科技、贸易等
    private static final String[] INDUSTRIES = {
            "科技", "电子", "贸易", "实业", "建设", "投资", "医疗", "环保", "物流", "金融",
            "通信", "网络", "教育", "文化", "广告", "房地产", "餐饮", "旅游", "能源", "汽车"
    };

    // 公司类型后缀
    private static final String[] SUFFIXES = {
            "有限公司", "股份有限公司", "集团有限公司", "科技有限公司", "公司", "企业", "集团", "投资有限公司", "实业有限公司", "发展有限公司"
    };
    private static final String[] PROVINCES = {
            "京", "津", "冀", "晋", "蒙", "辽", "吉", "黑", "沪", "苏", "浙", "皖", "闽", "赣", "鲁",
            "豫", "鄂", "湘", "粤", "桂", "琼", "渝", "川", "贵", "云", "藏", "陕", "甘", "青", "宁",
            "新", "港", "澳"
    };

    private static final String LETTERS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
    private static final String NUMBERS = "0123456789";

    // 生成随机车牌号
    public static String generateLicensePlate() {
        Random random = new Random();

        // 省份简称
        String province = PROVINCES[random.nextInt(PROVINCES.length)];

        // 随机车牌号：1个字母 + 4个数字 + 1个字母
        char letter1 = LETTERS.charAt(random.nextInt(LETTERS.length()));
        StringBuilder numbers = new StringBuilder();
        for (int i = 0; i < 4; i++) {
            numbers.append(NUMBERS.charAt(random.nextInt(NUMBERS.length())));
        }
        char letter2 = LETTERS.charAt(random.nextInt(LETTERS.length()));

        return province + letter1 + numbers.toString() + letter2;
    }

    /**
     * 生成一个随机中国公司名称
     *
     * @return 随机中国公司名称
     */
    public static String getRandomChineseCompanyName() {
        Random random = new Random();
        String prefix = PREFIXES[random.nextInt(PREFIXES.length)]+PREFIXES[random.nextInt(PREFIXES.length)];
        String industry = INDUSTRIES[random.nextInt(INDUSTRIES.length)];
        String suffix = SUFFIXES[random.nextInt(SUFFIXES.length)];
        // 生成公司名称
        return prefix + industry + suffix;
    }

    //获取随机姓名
    public static String getRandomName() {
        String[] xingStrs = new String[]{"赵",
                "钱", "孙", "李", "周", "吴", "郑", "王", "冯", "陈", "褚", "卫", "蒋", "沈", "韩", "杨", "朱", "秦", "尤", "许", "何",
                "吕", "施", "张", "孔", "曹", "严", "华", "金", "魏", "陶", "姜", "戚", "谢", "邹", "喻", "柏", "水", "窦", "章", "云"};
        String[] mingStrs = new String[]{
                "甲", "乙", "丙", "丁", "戊", "己", "庚", "辛", "壬", "癸", "子", "丑", "寅", "卯", "辰", "巳", "午", "未", "申", "酉", "戌", "亥",
                "一", "二", "三", "四", "五", "六", "七", "八", "九", "十", "百", "千", "万", "亿", "兆", "拾", "佰", "仟", "万", "亿"};
        String res = xingStrs[(int) (Math.random() * xingStrs.length)] + mingStrs[(int) (Math.random() * mingStrs.length)];
        if (Math.random() < 0.65) {
            res = res + mingStrs[(int) (Math.random() * mingStrs.length)];
        }
        return res;
    }

    //获取随机字符串
    public static String getRandomFromStringArr(String[] arr) {
        return Arrays.asList(arr).get((int) (Math.random() * arr.length));
    }

    //获取随机整数
    public static Integer getRandomFromIntegerArr(Integer[] arr) {
        return Arrays.asList(arr).get((int) (Math.random() * arr.length));
    }

    //获取随机整数
    public static Integer getRandomInteger(int min, int max) {
        return (int) (Math.random() * (max - min + 1) + min);
    }

    //获取随机整数
    public static Long getRandomLong(Long min, Long max) {
        return min + (long) (new Random().nextDouble() * (max - min + 1));
    }


    //获取随机日期
    public static String getRandomDate() {
        return getRandomInteger(1980, 2024) + "-" + fillZero(getRandomInteger(1, 12)) + "-" + fillZero(getRandomInteger(1, 28));
    }

    //获取随机时间
    public static String getRandomTime() {
        return fillZero(getRandomInteger(0, 23)) + ":" + fillZero(getRandomInteger(0, 59)) + ":" + fillZero(getRandomInteger(0, 59));
    }

    //获取随机日期
    public static Date getRandomDate2(Date startDate, Date endDate) {
        if (startDate.after(endDate)) {
            throw new IllegalArgumentException("Start date must be before end date");
        }

        long startMillis = startDate.getTime();
        long endMillis = endDate.getTime();
        long randomMillis = startMillis + (long) (new Random().nextDouble() * (endMillis - startMillis));

        return new Date(randomMillis);
    }

    //补齐零
    public static String fillZero(int num) {
        return num < 10 ? "0" + num : num + "";
    }


    public static void main(String[] args) {
        for (int i = 0; i < 10; i++) {
            System.out.println(getRandomChineseCompanyName());
        }
    }

}
